package kr.hkit.androidcomplete01.chapter08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class HandlerOrder extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View vw = new MyView(this);
		vw.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction()==MotionEvent.ACTION_DOWN){
					Toast.makeText(getApplication(), "리스너 :터치이벤트 리시브드", Toast.LENGTH_LONG).show();
					return false;//false면 이거 뜨고 다음것도 뜬다. 
				}
				return false;
			}
		});
		setContentView(vw);
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		super.onTouchEvent(event);
		if(event.getAction()==MotionEvent.ACTION_DOWN){
			Toast.makeText(getApplication(), "액티비티 :터치이벤트 리시브드", Toast.LENGTH_LONG).show();
			return true;
		}
		return false;
	}
	
	class MyView extends View{
		public MyView(Context context) {
			super(context);
		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
			if(event.getAction()==MotionEvent.ACTION_DOWN){
				Toast.makeText(getApplication(), "뷰 :터치이벤트 리시브드", Toast.LENGTH_LONG).show();
				return false;
			}
			return false;
		}
	}
}
